package cn.jingyinghui.controller;

import cn.jingyinghui.rules.customer.User;
import cn.jingyinghui.service.RuleService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/rules")
public class RuleController {

    private final RuleService ruleService;

    public RuleController(RuleService ruleService) {
        this.ruleService = ruleService;
    }

    @GetMapping("/apply")
    public User applyDiscount(@RequestParam String name, @RequestParam boolean vip, @RequestParam int age) {
        User user = new User(name, vip, age);
        return ruleService.applyRules(user);
    }
}
